package org.example.hospital_registration_system.mapper;


import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.hospital_registration_system.model.User;

@Mapper
public interface IUserInfoMapper {

    /*
     * 根据用户名查找信息
     * */
    @Select("SELECT * FROM user WHERE username = #{username}")
    User selectUserByUsername( String username);

    /*
     * 根据用户id查用户名
     * */
    @Select("SELECT username FROM user WHERE user_id = #{userId}")
    String selectUserById( Integer userId);

    /*
     * 添加用户信息
     * */
    @Insert({
            "INSERT INTO user (",
            "username, password, gender, phone, address",
            ") VALUES (",
            "#{username}, #{password}, #{gender}, #{phone}, #{address}",
            ")"
    })
    Integer insertUser(User user);

}
